import 'package:flutter/material.dart';
import 'package:luckiness/utils/general.dart';
import '../components/ffgood_style.dart';
class FFListView extends StatelessWidget {

  final String title;
  final String subtitle;
  FFListView({
    this.title,
    this.subtitle,
  });

  Widget getHeadWidget(BuildContext context) {
    double scale = widthScale(context);
    Row row = Row(
      children: <Widget>[
        Column(
          mainAxisSize:MainAxisSize.min,
          mainAxisAlignment: MainAxisAlignment.start,
          children:<Widget>[
            Text(
              title,
              style:TextStyle(fontWeight:FontWeight.bold, color:Color.fromRGBO(56, 56, 56, 1.0), fontSize:13 * scale),
            ),
            subtitle.length > 0 ? Text(
              subtitle,
              style:TextStyle(fontWeight:FontWeight.normal, color:Color.fromRGBO(166, 166, 166, 1.0), fontSize:10 * scale),
            ) : Container()
          ]
        )
      ],
    );
    return Padding(
      padding: EdgeInsets.fromLTRB(12, 10 * scale, 12, 10 * scale),
      child: row,
    );
  }

  Widget getCell(BuildContext context) {
    double scale = widthScale(context);
    Row row = Row(
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      crossAxisAlignment: CrossAxisAlignment.end,
      children: <Widget>[
        Container(
          width:70 * scale,
          height: 70 * scale,
          decoration:BoxDecoration(
            color: Colors.cyan,
            borderRadius: BorderRadius.circular(4.0),
            image: DecorationImage(image: AssetImage('assets/images/menu/goods.png'), fit:BoxFit.fill),
          ),
        ),
        Expanded(
          child:Container(
            padding: EdgeInsets.only(left:10),
            height:70 * scale,
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: <Widget>[
                Text('拿铁', style: TextStyle(fontWeight:FontWeight.bold, fontSize: 15, color: Colors.black54)),
                Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    Text('Latte', style: TextStyle(fontWeight:FontWeight.normal, fontSize: 11, color: Colors.black26)),
                    Text('默认：大/无糖/热', style: TextStyle(fontWeight:FontWeight.normal, fontSize: 11, color: Colors.black26)),
                  ],
                ),
                Text('￥27', style: TextStyle(fontWeight:FontWeight.bold, fontSize: 15, color: Colors.black54)),
              ],
            )
          )
        ),
      
        GestureDetector(
          onTap:(){
            print('添加 了');
            FFGoodStyle.ffShow(context);
          },
          child:Container(
            width: 30,
            height: 30,
            color: Colors.white,
            padding: EdgeInsets.fromLTRB(8, 8, 0, 0),
            child: Icon(Icons.add_circle, size:15.0, color:Color.fromRGBO(136, 175, 213, 1.0)),
          )
        )
      ],
    );

    Padding pad = Padding(padding: EdgeInsets.fromLTRB(12, 10, 12, 10), child:row);
    return Column(
      children:[
        pad,
        Divider(height:0, color: separatorLineColor,),
      ]
    );
  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build

    return Container(
      color:Colors.white,
      child:Column(
        mainAxisSize:MainAxisSize.min,
        children:[1, 2, 3, 3, 3].map((e){
          return getCell(context);
        }).toList()..insert(0, getHeadWidget(context)),
      )
    );
  }
  
}